#pragma once

#include"BinaryTree.h"
#include"Queue.h"


BTNode* BuyNode(int x)
{
	BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
	if (newnode == NULL)
	{
		perror("malloc fail");
		return NULL;
	}

	newnode->data = x;
	newnode->left = newnode->right = NULL;

	return newnode;
}

BTNode* CreatBinaryTree()
{
	BTNode* node1 = BuyNode(1);
	BTNode* node2 = BuyNode(2);
	BTNode* node3 = BuyNode(3);
	BTNode* node4 = BuyNode(4);
	BTNode* node5 = BuyNode(5);
	BTNode* node6 = BuyNode(6);
	BTNode* node7 = BuyNode(7);
	BTNode* node8 = BuyNode(8);
	BTNode* node9 = BuyNode(9);

	node1->left = node2;
	node1->right = node4;
	node2->left = node3;
	node2->right = node5;
	node4->left = node6;
	node4->right = node7;

	node3->left = node8;
	node3->right = node9;

	return node1;

}


int main()
{
	BTNode* root = CreatBinaryTree();
	InOrder(root);
	printf("\n");
	PostOrder(root);
	printf("\n");

	printf("TreeSize:%d\n", BinaryTreeSize(root));
	printf("TreeLeafSize:%d\n", BinaryTreeLeafSize(root));
	printf("TreeHight:%d\n", BinaryTreeHight(root));
	printf("TreeLevelKSize:%d\n", BinaryTreeLevelKSize(root,4));
	printf("TreeLevelOrder:");
	BinaryTreeLevelOrder(root);
	printf("\n");
	bool tep = BinaryTreeComplete(root);
	if (tep)
	{
		printf("yes\n");
	}
	else
	{
		printf("no\n");
	}
	return 0;
}
